<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>统计成绩平均值之上</title>
    <script>
      function getStatisticOverAverage(arr) {
        //使用数组reduce方法求取总成绩和，并取平均值
        var average =
          arr.reduce((total, current) => {
            return total + current;
          }, 0) / arr.length;
        //使用数组方法filter过滤获取大于平均数的值
        var num = arr.filter((m) => m >= average).length;
        console.log("统计成绩平均值之上共有：" + num + "人");
      }
      getStatisticOverAverage([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
    </script>
  </head>
  <body></body>
</html>
